﻿#pragma once

#include <hacks/net/socket_ops.h>


namespace hacks::net {

    typedef std::function<void(ev_os_sock_t incoming_fd)> acceptor_functor_t;

    class tcp_acceptor {

    public:
        tcp_acceptor(const shared_ev_loop &loop,
                     const ip_addr &addr);

    public:
        void set_accept_callback(acceptor_functor_t &&f);

        shared_ev_loop get_loop() const;

    private:
        void on_acceptor_event(ev_sock_fd &, int status, int evt);

    private:
        shared_ev_loop loop_;
        shared_ev_sock_fd acceptor_fd_;
        acceptor_functor_t accept_func_;
    };

}

